<template>
  <div class="header">
    <input v-model="searchValue" @input="searchChange" type="text" />
  </div>
</template>

<script>
import { useStore } from "vuex";
import { ref, watch, toRef } from "vue";
import { debounce } from "../mixin";
export default {
  setup(p, { emit }) {
    let store = useStore();
    let searchValue = ref("");

    // 搜索的结果

    const searchChange = debounce(function() {
      //   console.log(searchValue.value);
      emit("searchChange", searchValue.value);
      store.commit("push", searchValue.value);
    }, 1000);

    return {
      searchChange,
      searchValue,
    };
  },
};
</script>

<style lang="scss" scoped>
.header {
  width: 100%;
  height: 50px;
  background-color: red;
  display: flex;
  align-items: center;
  justify-content: center;
  input {
    border-radius: 25px;
    width: 80%;
    height: 80%;
  }
}
</style>
